package org.cbg.panel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;

import org.cbg.btn.TrslationMainBtn;
import org.cbg.until.TraslationTableUntil;
import org.come.until.CutButtonImage;

import com.tool.tcpimg.UIUtils;



/**
 * 我要买首页搜索结果面板
 * 
 * @author Administrator
 * 
 */
public class TraslationWantBuyShouyeSousuojieguoJpanel extends JPanel {
    /**
     * 按钮 返回back，
     */
    private TrslationMainBtn back;

    /**
     * 页码,上排序,下排序,勾选框
     */
    private JLabel yema, upSort, downSort, showperioditems;

    /**
     * 勾选框是否勾选（1勾选，0未勾选） 排序（0为默认排序， 1 为升序 ，2 为降序）
     */
    private int showperioditemsFlag = 0, showOrder = 0;

    private JScrollPane jScrollPane;

    /**
     * 页码按钮，首页，末页 , 左箭头, 右箭头
     */
    private TrslationMainBtn shouye, moye, leftArrows, rightArrows;

    /**
     * 当前页码 最大页码
     *
     */
    private int dangqianyeshu = 1, zuidayema = 50;

    public TraslationWantBuyShouyeSousuojieguoJpanel() {
        this.setPreferredSize(new Dimension(760, 460));
        this.setOpaque(false);
        this.setLayout(null);

        back = new TrslationMainBtn("inkImg/number/b4/fhaj.png", 1, UIUtils.COLOR_BTNTEXT, UIUtils.TEXT_FONT, 16, "", this);
        back.setBounds(9, 9, 57, 26);
        this.add(back);

        jScrollPane = new JScrollPane();
        jScrollPane.setOpaque(false);
        // jScrollPane.setBounds(8, 46, 760, 300);
        jScrollPane.setBorder(null);
        // TraslationTableJPanel.TableModel(jTable, jScrollPane);
        jScrollPane = new JScrollPane();
        jScrollPane.setBounds(8, 63, 750, 372);
        // 整理数据添加到面板上
        TraslationTableUntil.TableModel(jScrollPane, 10);
        this.add(jScrollPane);

        /**
         * 页码设置
         */
        yema = new JLabel(dangqianyeshu + "/" + zuidayema);
        yema.setBounds(258+91, 442, 58, 17);
        yema.setForeground(UIUtils.COLOR_cbg8);
        yema.setOpaque(false);

        yema.setHorizontalAlignment(SwingConstants.CENTER);
        this.add(yema);

        shouye = new TrslationMainBtn("inkImg/number/b4/fy1.png", 1, UIUtils.COLOR_BTNTEXT, UIUtils.TEXT_FONT, 17, "",
                this);
        shouye.setBounds(287, 442, 40, 20);
        // shouye.setBackground(null);
        shouye.setOpaque(false);
        shouye.setBorder(null);
        this.add(shouye);

        leftArrows = new TrslationMainBtn("inkImg/number/b4/fy2.png", 1, 18, "", this);
        leftArrows.setBounds(326, 442, 19, 20);
        leftArrows.setBorder(null);
        leftArrows.setBackground(null);
        leftArrows.setOpaque(false);
        this.add(leftArrows);

        moye = new TrslationMainBtn("inkImg/number/b4/fy4.png", 1, UIUtils.COLOR_BTNTEXT, UIUtils.TEXT_FONT, 19, "", this);
        moye.setBounds(433, 442, 40, 20);
        moye.setBorder(null);
        moye.setBackground(null);
        moye.setOpaque(false);
        this.add(moye);

        rightArrows = new TrslationMainBtn("inkImg/number/b4/fy3.png", 1, 20, "", this);
        rightArrows.setBounds(411, 442, 19, 20);
        rightArrows.setBorder(null);
        rightArrows.setBackground(null);
        rightArrows.setOpaque(false);
        this.add(rightArrows);

        /**
         * 排序
         */
        upSort = new JLabel();
        upSort.setBounds(280, 38, 10, 18);
        upSort.setBorder(null);
        upSort.setBackground(null);
        upSort.setOpaque(false);
        upSort.setIcon(CutButtonImage.getImage("inkImg/old/1/Z1002.png", 10, 18));
        this.add(upSort);
        upSort.addMouseListener(new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseExited(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                upSort.setIcon(CutButtonImage.getImage("inkImg/old/1/Z1003.png", 10, 18));
                downSort.setIcon(CutButtonImage.getImage("inkImg/old/1/Z1004.png", 10, 18));
                dangqianyeshu = 1;
                showOrder = 1;
                /**
                 * 上传数据到服务器中搜索数据
                 */
                TraslationWantBuyShouyeJpanel.souyeSousuo(dangqianyeshu, showperioditemsFlag, showOrder,
                        TraslationWantBuyShouyeJpanel.searchGoodsBean);
            }
        });

        downSort = new JLabel();
        downSort.setBounds(296, 39, 10, 18);
        downSort.setBorder(null);
        downSort.setBackground(null);
        downSort.setOpaque(false);
        downSort.setIcon(CutButtonImage.getImage("inkImg/old/1/Z1004.png", 10, 18));
        this.add(downSort);
        downSort.addMouseListener(new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseExited(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                upSort.setIcon(CutButtonImage.getImage("inkImg/old/1/Z1002.png", 10, 18));
                downSort.setIcon(CutButtonImage.getImage("inkImg/old/1/Z1005.png", 10, 18));
                dangqianyeshu = 1;
                showOrder = 2;
                /**
                 * 上传数据到服务器中搜索数据
                 */
                TraslationWantBuyShouyeJpanel.souyeSousuo(dangqianyeshu, showperioditemsFlag, showOrder,
                        TraslationWantBuyShouyeJpanel.searchGoodsBean);

            }
        });

        /**
         * 勾选框showperioditems
         */
        showperioditems = new JLabel();
        showperioditems.setBounds(446, 6, 15, 15);
        showperioditems.setOpaque(false);
        showperioditems.setBorder(null);
        this.add(showperioditems);
        showperioditems.addMouseListener(new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseExited(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                if (showperioditemsFlag == 0) {
                    showperioditems.setIcon(CutButtonImage.getImage("skin/8100226/button/13.png", 15, 15));
                    showperioditemsFlag = 1;

                    TraslationWantBuyShouyeJpanel.souyeSousuo(dangqianyeshu, showperioditemsFlag, showOrder,
                            TraslationWantBuyShouyeJpanel.searchGoodsBean);
                } else {
                    showperioditems.setIcon(null);
                    showperioditemsFlag = 0;
                    TraslationWantBuyShouyeJpanel.souyeSousuo(dangqianyeshu, showperioditemsFlag, showOrder,
                            TraslationWantBuyShouyeJpanel.searchGoodsBean);
                }
            }
        });

    }

    private ImageIcon icon1;

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        if (icon1 == null) {
            icon1 = new ImageIcon("inkImg/number/b4/scxq.png");
        }
        g.drawImage(icon1.getImage(), 0, 5, 760, 55, this);

    }

    /**
     * 刷新页面的页码
     *
     * @param
     * @param zuidayema
     *
     */
    public void setPage(int zuidayema) {
        this.zuidayema = zuidayema;
        yema.setText(this.dangqianyeshu + "/" + this.zuidayema);
    }

    public JLabel getYema() {
        return yema;
    }

    public TrslationMainBtn getBack() {
        return back;
    }

    public void setBack(TrslationMainBtn back) {
        this.back = back;
    }

    public void setYema(JLabel yema) {
        this.yema = yema;
    }

    public JLabel getUpSort() {
        return upSort;
    }

    public void setUpSort(JLabel upSort) {
        this.upSort = upSort;
    }

    public JLabel getDownSort() {
        return downSort;
    }

    public void setDownSort(JLabel downSort) {
        this.downSort = downSort;
    }

    public JLabel getShowperioditems() {
        return showperioditems;
    }

    public void setShowperioditems(JLabel showperioditems) {
        this.showperioditems = showperioditems;
    }

    public int getShowperioditemsFlag() {
        return showperioditemsFlag;
    }

    public void setShowperioditemsFlag(int showperioditemsFlag) {
        this.showperioditemsFlag = showperioditemsFlag;
    }

    public JScrollPane getjScrollPane() {
        return jScrollPane;
    }

    public void setjScrollPane(JScrollPane jScrollPane) {
        this.jScrollPane = jScrollPane;
    }

    public int getDangqianyeshu() {
        return dangqianyeshu;
    }

    public void setDangqianyeshu(int dangqianyeshu) {
        this.dangqianyeshu = dangqianyeshu;
    }

    public int getZuidayema() {
        return zuidayema;
    }

    public void setZuidayema(int zuidayema) {
        this.zuidayema = zuidayema;
    }

    public int getShowOrder() {
        return showOrder;
    }

    public void setShowOrder(int showOrder) {
        this.showOrder = showOrder;
    }

    public ImageIcon getIcon1() {
        return icon1;
    }

    public void setIcon1(ImageIcon icon1) {
        this.icon1 = icon1;
    }

    public TrslationMainBtn getShouye() {
        return shouye;
    }

    public void setShouye(TrslationMainBtn shouye) {
        this.shouye = shouye;
    }

    public TrslationMainBtn getMoye() {
        return moye;
    }

    public void setMoye(TrslationMainBtn moye) {
        this.moye = moye;
    }

    public TrslationMainBtn getLeftArrows() {
        return leftArrows;
    }

    public void setLeftArrows(TrslationMainBtn leftArrows) {
        this.leftArrows = leftArrows;
    }

    public TrslationMainBtn getRightArrows() {
        return rightArrows;
    }

    public void setRightArrows(TrslationMainBtn rightArrows) {
        this.rightArrows = rightArrows;
    }

}
